#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int removeElement(vector<int>& nums, int val)
    {
        int ret = nums.size();
        int i = 0;
        while (i < ret)
        {
            while (i < ret && nums[i] == val)
            {
                swap(nums[i], nums[ret - 1]);
                --ret;
            }
            ++i;
        }
        return ret;
    }
};